﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public class MonthPlanSummary
    {
        private readonly DAL.MonthPlanSummary dal = new DAL.MonthPlanSummary();
        public MonthPlanSummary()
        { }
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="year">年份</param>
        /// <param name="month">月份</param>
        /// <param name="emplNo">人员编号</param>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public bool Exists(decimal year, decimal month, string emplNo, string entityNo, string type)
        {
            return dal.Exists(year, month, emplNo, entityNo, type);
        }
        /// <summary>
        /// 获取主部门
        /// </summary>
        /// <returns></returns>
        public DataSet GetDept()
        {
            return dal.GetDept();
        }
        /// <summary>
        /// 需要考核的部门（不是外派机构）
        /// </summary>
        /// <returns>数据列表</returns>
        public DataSet GetCheckDept()
        {
            return dal.GetCheckDept();
        }
        /// <summary>
        /// 需要考核人员
        /// </summary>
        /// <param name="fDeptNO">部门编号</param>
        /// <returns>数据列表</returns>
        public DataSet GetChechEmp(string fDeptNO)
        {
            return dal.GetChechEmp(fDeptNO);
        }
        /// <summary>
        /// 获取系统当前时间
        /// </summary>
        /// <returns></returns>
        public DataSet GetSysDate() 
        {
            return dal.GetSysDate();
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary> modelList = new List<ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 得到工作人员的名字
        /// </summary>
        /// <param name="empNo">人员编号</param>
        /// <returns>字符</returns>
        public string GetEmpName(string empNo)
        {
            return dal.GetEmpName(empNo);
        }
        /// <summary>
        /// 获取是否能补录绩效考核
        /// </summary>
        /// <param name="empNo">人员编号</param>
        /// <returns></returns>
        public string GetAllowAddtionInsPlan(string empNo)
        {
            return dal.GetAllowAddtionInsPlan(empNo);
        }
        /// <summary>
        /// 是否参与绩效考核
        /// </summary>
        /// <param name="empNo"></param>
        /// <returns></returns>
        public string GetCheck(string empNo)
        {
            return dal.GetCheck(empNo);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary GetModel(decimal year, decimal month, string emplNo, string entityNo, string type)
        {
            return dal.GetModel(year, month, emplNo, entityNo, type);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary model)
        {
            return dal.Add(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Addition(ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary model)
        {
            return dal.Addition(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ElingOA6_Admin_DSJCJ.Model.MonthPlanSummary model)
        {
            return dal.Update(model);
        }

         /// <summary>
        /// 需要绩效考核的人员名单
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public DataSet GetListByEntityNo(string entityNo, string startDate, string endDate)
        {
            return dal.GetListByEntityNo(entityNo, startDate, endDate);
        }

        /// <summary>
        /// 需要绩效考核的部门
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public DataSet GetDeptListByEntityNo(string entityNo)
        {
            return dal.GetDeptListByEntityNo(entityNo);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="emplNo"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public DataSet GetModelIsWork(string emplNo, string entityNo)
        {
            return dal.GetModelIsWork(emplNo, entityNo);
        }

         /// <summary>
        /// 需要绩效考核的人员名单
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public DataTable GetListByEntityNo(string entityNo)
        {
            return dal.GetListByEntityNo(entityNo).Tables[0];
        }
        /// <summary>
        /// 更新绩效台账人员
        /// </summary>
        /// <param name="emplModelList"></param>
        public void UpdataEmpl(List<Model.HREmpl> emplModelList)
        {
            dal.UpdataEmpl(emplModelList);
        }
        /// <summary>
        /// 允许补录其他绩效台账人员
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public DataTable GetListAllowAddtionInsPlanByEntityNo(string entityNo)
        {
            return dal.GetListAllowAddtionInsPlanByEntityNo(entityNo).Tables[0];
        }
        /// <summary>
        /// 更新绩效台账人员
        /// </summary>
        /// <param name="emplModelList"></param>
        public void UpdataEmplAllowAddtionInsPlan(List<Model.HREmpl> emplModelList)
        {
            dal.UpdataEmplAllowAddtionInsPlan(emplModelList);
        }
    }
}
